using IQIGame.Onigao.Game;
using IQIGame.Onigao.GamePlay;
using System.Collections.Generic;

namespace IQIGame.Onigao.Logic
{
    /// <summary>
    /// 给玩家增加道具
    /// </summary>
    public class ExecAddItem : BaseServiceExecution
    {
        public override void Execute(LevelRegion region, LevelPlayer player)
        {
            ExecParamAddItem config = _config as ExecParamAddItem;
            if (config.items == null || config.items.Count <= 0)
            {
                LogicLog.LogError("添加道具执行参数不包含任何道具。");
                return;
            }
            List<int> tempItems = ListPool<int>.Get();
            foreach (var kv in config.items)
            {
                tempItems.Add(kv.cid);
                tempItems.Add(kv.num);
            }
            LogicItemModule.Instance.AddItem(player.logicPlayer, tempItems, LgLevelReasonId.ServiceAddItem);
            ListPool<int>.Put(tempItems);
        }
    }
}
